<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="125">
            <Row  class="query-form">
                <Col span="8">
                    <FormItem label="所属单位：">
                        <cascaderDom ref="queryOrgCascader" @setOrgInfo="setOrgId" :rootOrgId="companyId" class="query-form-el" :orgTree="true"></cascaderDom>
                    </FormItem>
                </Col>
                <Col span="8" v-if="!switchFlag" offset="8">
                    <!--<Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>-->
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>

            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!"
               :loading='pageStatus.loading' border :columns="columns1" :data="dataTable">
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>


    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import {sessionStorage, cookie} from '@/common/cacheUtils.js';
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    export default {
        components: {cascaderDom},
        data() {
            return {
                ...this.createCommonDataField(),
                columns1: [
                    {title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    {key: 'twoLevelName', title: '二级集团', align: 'center', minWidth: 200},
                    // {key: 'companyName', title: '单位', align: 'center', minWidth: 180},
                    {title: '重型载货运输车辆', align: 'center', children:[
										     {title: '电动（量）', align: 'center', minWidth: 80,children:[
														{key: 'electric1_1', title: '充电', align: 'center', minWidth: 80},
														{key: 'electric2_1', title: '换电', align: 'center', minWidth: 80},
													  {key: 'electricNum1', title: '电动总数', align: 'center', minWidth: 80}
												 ]},
												 {title: '燃油（量）', align: 'center', minWidth: 80,children:[
													 {key: 'emission1_1', title: '国1', align: 'center', minWidth: 80},
													 {key: 'emission2_1', title: '国2', align: 'center', minWidth: 80},
													 {key: 'emission3_1', title: '国3', align: 'center', minWidth: 80},
													 {key: 'emission4_1', title: '国4', align: 'center', minWidth: 80},
													 {key: 'emission5_1', title: '国5', align: 'center', minWidth: 80},
													 {key: 'emission6_1', title: '国6', align: 'center', minWidth: 80},
													 {key: 'fuelNum1', title: '燃油总数', align: 'center', minWidth: 80}
												 ]},
												 {title: '燃气、氢能（量）', align: 'center', minWidth: 80,children:[
													 {key: 'gas5_1', title: '国5', align: 'center', minWidth: 80},
													 {key: 'gas6_1', title: '国6', align: 'center', minWidth: 80},
													 {key: 'gasNum1', title: '燃气、氢能总数', align: 'center', minWidth: 100}
												 ]},
                           {key: 'sum1', title: '总数', align: 'center', minWidth: 80},
                        ]},
                    {title: '非道路移动机械电动', align: 'center', children:[
                        {title: '电动（量）', align: 'center', minWidth: 80,children:[
														{key: 'electric1_2', title: '充电', align: 'center', minWidth: 80},
														{key: 'electric2_2', title: '换电', align: 'center', minWidth: 80},
                          	{key: 'electricNum2', title: '电动总数', align: 'center', minWidth: 80}
                        ]},
                        {title: '燃油（量）', align: 'center', minWidth: 80,children:[
													{key: 'emission1_2', title: '国1', align: 'center', minWidth: 80},
													{key: 'emission2_2', title: '国2', align: 'center', minWidth: 80},
													{key: 'emission3_2', title: '国3', align: 'center', minWidth: 80},
													{key: 'emission4_2', title: '国4', align: 'center', minWidth: 80},
													{key: 'emission5_2', title: '国5', align: 'center', minWidth: 80},
													{key: 'emission6_2', title: '国6', align: 'center', minWidth: 80},
                        	{key: 'fuelNum2', title: '燃油总数', align: 'center', minWidth: 80}
                        ]},
												{title: '燃气、氢能（量）', align: 'center', minWidth: 80,children:[
													 {key: 'gas5_2', title: '国5', align: 'center', minWidth: 80},
													 {key: 'gas6_2', title: '国6', align: 'center', minWidth: 80},
													 {key: 'gasNum2', title: '燃气、氢能总数', align: 'center', minWidth: 100}
												]},
                        {key: 'sum2', title: '总数（量）', align: 'center', minWidth: 80},
                      ]},
                ],
                tableHeight: 10,
                companyId:'',
                // api
                queryUrl: Api.reportEnTable.replace('{{table}}', 'MobileSourceEnvMobileMachinery'),

            }
        },
        mounted() {
            this.companyId=sessionStorage('userId').getObject('userId').companyId
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.query();
        },
        methods: {
            ...pageCommonFunction,
            query() {
                this.queryAjax();
            },
            setOrgId(data) {
                this.dataToQuery.orgId = data[data.length - 1];
            },

        },
        computed: {},

    }
</script>

<style lang='css' scoped>
    @import '../../../index.css';
</style>
